//
//  CNUser.swift
//  Ccweibo
//
//  Created by 陈锦聪 on 16/3/26.
//  Copyright © 2016年 Coco. All rights reserved.
//

import UIKit

class CNUser: NSObject {

    /// 用户id
    var id: Int64 = 0
    /// 用户昵称
    var screen_name: String?
    /// 用户头像地址
    var profile_image_url: String?
    /// 认证类型
    var verified_type: Int = -1 {
        didSet {
            switch verified_type {
            case 0:
                verified_typeImage = UIImage(named: "avatar_vip")
            case 2, 3, 5:
                verified_typeImage = UIImage(named: "avatar_enterprise_vip")
            case 220:
                verified_typeImage = UIImage(named: "avatar_grassroot")
            default:
                verified_typeImage = nil
            }
        }
    }
    /// 认证类型图片
    var verified_typeImage: UIImage?
    /// 会员等级
    var mbrank: Int = 0 {
        didSet {
            if mbrank > 0 && mbrank < 7 {
                mbrankImage = UIImage(named: "common_icon_membership_level\(mbrank)")
            } else {
                mbrankImage = nil
            }
        }
    }
    /// 会员等级图片
    var mbrankImage: UIImage?
    
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
//        CNPrint(item: "UndefinedKey: \(key)")
    }
    
    override var description: String {
        
        let keys = ["id", "screen_name", "profile_image_url", "verified_type", "mbrank"]
        return "\n\tUser: \(dictionaryWithValuesForKeys(keys).description)"
    }
}
